package com.okyai.cms.service.impl;

import java.util.List;
import com.okyai.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.okyai.cms.mapper.CmsContentMapper;
import com.okyai.cms.domain.CmsContent;
import com.okyai.cms.service.ICmsContentService;
import com.okyai.common.core.text.Convert;

/**
 * 文章Service业务层处理
 * 
 * @author okyai
 * @date 2020-12-03
 */
@Service
public class CmsContentServiceImpl implements ICmsContentService 
{
    @Autowired
    private CmsContentMapper cmsContentMapper;

    /**
     * 查询文章
     * 
     * @param id 文章ID
     * @return 文章
     */
    @Override
    public CmsContent selectCmsContentById(Long id)
    {
        return cmsContentMapper.selectCmsContentById(id);
    }

    /**
     * 查询文章列表
     * 
     * @param cmsContent 文章
     * @return 文章
     */
    @Override
    public List<CmsContent> selectCmsContentList(CmsContent cmsContent)
    {
        return cmsContentMapper.selectCmsContentList(cmsContent);
    }

    /**
     * 新增文章
     * 
     * @param cmsContent 文章
     * @return 结果
     */
    @Override
    public int insertCmsContent(CmsContent cmsContent)
    {
        cmsContent.setCreateTime(DateUtils.getNowDate());
        return cmsContentMapper.insertCmsContent(cmsContent);
    }

    /**
     * 修改文章
     * 
     * @param cmsContent 文章
     * @return 结果
     */
    @Override
    public int updateCmsContent(CmsContent cmsContent)
    {
        cmsContent.setUpdateTime(DateUtils.getNowDate());
        return cmsContentMapper.updateCmsContent(cmsContent);
    }

    /**
     * 删除文章对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteCmsContentByIds(String ids)
    {
        return cmsContentMapper.deleteCmsContentByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除文章信息
     * 
     * @param id 文章ID
     * @return 结果
     */
    @Override
    public int deleteCmsContentById(Long id)
    {
        return cmsContentMapper.deleteCmsContentById(id);
    }
}
